package com.info.zhiduoduo.admin.model.formbean.crowdsource;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.info.zhiduoduo.common.constants.Constants;
import com.info.zhiduoduo.common.constants.company.CompanyPayType;
import com.info.zhiduoduo.common.constants.crowdsource.CrowdsourceProjectType;
import com.info.zhiduoduo.common.excelconverter.UserTypeConverter;

import java.util.Date;

import com.info.zhiduoduo.common.validator.ExcelValid;
import com.info.zhiduoduo.repository.entity.company.Company;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceProject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ImportDealCrowdsourceProjectFormBean {

    @ExcelProperty(index = 0)
    @ApiModelProperty("序号")
    private Integer row;

    @ExcelProperty(index = 1, converter = UserTypeConverter.class)
    @ApiModelProperty("用户类型")
    private int userType;

    @ExcelProperty(index = 2)
    @ApiModelProperty("创客工作室全称")
    private String username;

    @ExcelProperty(index = 3)
    @ApiModelProperty("收款方姓名")
    @ExcelValid(message = "收款方姓名不能为空")
    private String acctName;

    @ExcelProperty(index = 4)
    @ApiModelProperty("收款方账户")
    @ExcelValid(message = "收款方账户不能为空")
    private String acctno;

    @ExcelProperty(index = 5)
    @ApiModelProperty("账户类型:1:代表个人账户 2:代表企业账户")
    private String accttype;

    @ExcelProperty(index = 6)
    @ApiModelProperty("收款方开户行行号")
    private String bankno;

    @ExcelProperty(index = 7)
    @ApiModelProperty("收款方开户行名称")
    private String bankname;

    @ExcelProperty(index = 8)
    @ApiModelProperty("用途")
    private String purpose;

    @ExcelProperty(index = 9)
    @ApiModelProperty("备注")
    private String remark;

    @ExcelProperty(index = 10)
    @ApiModelProperty("金额")
    private double itemAmount;

    @ExcelProperty(index = 11)
    @ApiModelProperty("收款方身份证号")
    @ExcelValid(message = "身份证号不能为空")
    private String idno;

    @ExcelProperty(index = 12)
    @ApiModelProperty("收款方联系方式")
    @ExcelValid(message = "收款方联系方式不能为空")
    private String phone;

    @ExcelProperty(index = 13)
    @ApiModelProperty("企业名称")
    @ExcelValid(message = "企业名称不能为空")
    private String compname;

    @ExcelProperty(index = 14)
    @ApiModelProperty("项目名")
    @ExcelValid(message = "项目名不能为空")
    private String projectName;

    @ExcelProperty(index = 15)
    @ApiModelProperty("项目描述")
    @ExcelValid(message = "项目描述不能为空")
    private String projectDesc;

    @ExcelProperty(index = 16)
    @ApiModelProperty("发票内容")
    @ExcelValid(message = "发票内容不能为空")
    private String invoiceContent;

    @ExcelProperty(index = 17)
    @ApiModelProperty("项目税费")
    private double taxFee;

    @ExcelProperty(index = 18)
    @ApiModelProperty("项目服务费")
    private double serviceCharge;

    @ExcelProperty(index = 19)
    @ApiModelProperty("创建日期")
    @ExcelValid(message = "创建日期不能为空")
    private Date createtime;

    @ExcelProperty(index = 20)
    @ApiModelProperty("完成时间")
    private Date finishtime;

    @ExcelProperty(index = 21)
    @ApiModelProperty("运营主体")
    @ExcelValid(message = "运营主体不能为空")
    private String operatingSubject;

    //解析后新增字段
    //创客ID 或 自然人ID
    @ExcelIgnore
    private Integer userid;
    @ExcelIgnore
    private Integer partyId;
    //企业ID
    @ExcelIgnore
    private int compid;

    public CrowdsourceProject toEntity(Company company, ImportDealCrowdsourceProjectFormBean formBean) {
        return new CrowdsourceProject().setCompid(company.getCompid())
                                       .setCompname(company.getCompname())
                                       .setProjectType(CrowdsourceProjectType.NORMAL)
                                       .setHighTaxRate(company.getHighTaxRate())
                                       .setLowTaxRate(company.getLowTaxRate())
                                       .setInvoiceType(String.valueOf(company.getInvoiceType()))
                                       .setInvoiceContent(formBean.getInvoiceContent())
                                       .setPartyId(partyId)
                                       .setPartnerBrokerageRate(0d)
                                       .setProjectDesc(formBean.getProjectDesc())
									   .setProjectServiceRate(0d)
                                       .setState(Constants.CROWDSOURCE_PROJECT_ALL_PAID)
                                       .setFinishtime(formBean.getFinishtime())
									   .setSupplement(Constants.TRUE)
									   .setCreatetime(formBean.getCreatetime())
									   .setSupplementTime(new Date());
    }
}
